package com.etboot.modules.activiti.serviceimpl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.etboot.modules.activiti.dao.mapper.ActCategoryMapper;
import com.etboot.modules.activiti.entity.ActCategory;
import com.etboot.modules.activiti.service.ActCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 流程分类接口实现
 *
 * @author xboot
 */
@Slf4j
@Service
@Transactional
public class ActCategoryServiceImpl extends ServiceImpl<ActCategoryMapper, ActCategory> implements ActCategoryService {
    @Autowired
    private ActCategoryMapper actCategoryMapper;

    @Override
    public List<ActCategory> findByParentIdOrderBySortOrder(String parentId) {
        return actCategoryMapper.selectList(Wrappers.<ActCategory>lambdaQuery().eq(ActCategory::getParentId, parentId).orderByAsc(ActCategory::getSortOrder));
    }

    @Override
    public List<ActCategory> findByTitleLikeOrderBySortOrder(String title) {
        return actCategoryMapper.selectList(Wrappers.<ActCategory>lambdaQuery().like(ActCategory::getTitle, title).orderByAsc(ActCategory::getSortOrder));
    }
}